//登陆成功,并保存相关信息
import SysApi from "@/api/sys/SysApi";
import store from "@/store";
import router from "@/router";

export function loginSuccess(token: string) {
    SysApi.getUserInfo().success(result => {
        if (result.data?.menuList) {
            result.data.menuList[0].isHeaderActive = true;
        }
        store.commit("localStorage/routeList", result.data?.routeList);
        store.commit("localStorage/menuList", result.data?.menuList);
        router.replace('/index')
    }).request();
}

//退出登陆
export function logout() {
    router.replace('/login')
    store.commit("sessionStorage/cleanAll", null);
    store.commit("localStorage/cleanAll", null);
}